package com.superatom.concurrent.basic.executor.exception;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class NaiveExceptionHanding {

    // 在ExceptionThread任务中模拟抛出一个运行时异常
    public void run() {
        throw new RuntimeException();
    }

    public static void main(String[] args) {
        try {
            ExecutorService exec = Executors.newCachedThreadPool();
            // 异常会传播到run()方法外面
            exec.execute(new ExceptionThread());
        }catch (RuntimeException ue){
            // 这种try-catch是无法捕获到异常
            System.out.println("Exception has been handle!");
        }
    }
}
